package com.scpii.universal.dispatch.job;

import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.scpii.universal.dispatch.Const;
import com.scpii.universal.dispatch.Dispatcher;
import com.scpii.universal.dispatch.domain.CompileTask;

/**
 * 缓存数据清理
 * 
 * @author chenxin
 * 
 */
@Component
public class CleanCacheJob {

	private static final Logger log = LoggerFactory
			.getLogger(CleanCacheJob.class);

	public void run() throws JobExecutionException {
		log.info("缓存调度清理程序开始");
		for (Integer key : Dispatcher.tasks.keySet()) {
			CompileTask task = Dispatcher.tasks.get(key);
			if (task.getStatus().equals(Const.COMPLETE_COMPILE_STATE)) {
				Integer taskid = task.getCompileTaskId();
				Dispatcher.tasks.remove(taskid);
			}
		}
		log.info("缓存调度清理程序结束");
	}
}
